date/time picker control instances

Hello dxl Community,

This is probably the worst day of the year to be raising issues on the Date but here goes:

The Date DB object is exhibiting inconsistent behaviour:

DB TestCaseHistoryDB = create("TestCaseHistory ", styleCentered)
Date init = dateAndTime(today)   
DBE oDateDBE1 = date(TestCaseHistoryDB, 30,init, true)
DBE oDateDBE2 = date(TestCaseHistoryDB, 30,init, true)
 
 
void makeTestCaseHistory(DB winDB) {
  
 
    Date oDate = get(oDateDBE1)
    Date oDate2 = get(oDateDBE2)
    string sDate = stringOf(oDate)
    string sDate2 = stringOf(oDate2)
    print oDate  "\t"
    print oDate2  "\t"
 
 
    print "\n"
 
 
 
}
apply(TestCaseHistoryDB, "Go", makeTestCaseHistory)
realize(TestCaseHistoryDB)
show(TestCaseHistoryDB)

 

I was playing around with selecting dates. On the fourth selection, the date format changes for some unknown reason.

01/04/14 11:51:21 01/04/14 11:51:21   // press go
02/04/14 11:51:21 01/04/14 11:51:21  // select a different date/ press go
02/04/14 11:51:21 03/04/14 11:51:21  // repeat for 3 April
02/04/14 11:51:21 04/30/14 11:51:21   ///  Change the date date to April 30. sudden change of format! 

 

The behavioiur is the same if you force formats (with StringOf, local,etc). What is causing this format jump?


MyDeveloerWorks - Tue Apr 01 05:57:56 EDT 2014

Re: date/time picker control instances
SGreen - Tue Apr 01 14:34:52 EDT 2014

There is a problem here in the handling of dates which include a time component. It has been raised internally as a defect.

A possible workaround would involve splitting the time and date components into separate DBEs. E.g. in code such as the following:

"

DB TestCaseHistoryDB = create("TestCaseHistory ", styleCentered)
//Date init = dateAndTime(today)
Date init = today
DBE oDateDBE1 = date(TestCaseHistoryDB, 30, init, true)
DBE timeField = field (TestCaseHistoryDB, "Time : ", "00:00:00", 25)

void makeTestCaseHistory(DB winDB) {

    Date oDate = get(oDateDBE1)
    Date oDate2 = dateOnly oDate

    string sDate = stringOf(oDate)
    string sTime = get timeField
    print sDate " " sTime "\n"
}

apply(TestCaseHistoryDB, "Go", makeTestCaseHistory)
realize(TestCaseHistoryDB)
show(TestCaseHistoryDB)

"

It would be good to add verification of the time value, as it currently stands any string will be accepted.

Re: date/time picker control instances
MyDeveloerWorks - Wed Apr 02 09:26:15 EDT 2014

SGreen - Tue Apr 01 14:34:52 EDT 2014

There is a problem here in the handling of dates which include a time component. It has been raised internally as a defect.

A possible workaround would involve splitting the time and date components into separate DBEs. E.g. in code such as the following:

"

DB TestCaseHistoryDB = create("TestCaseHistory ", styleCentered)
//Date init = dateAndTime(today)
Date init = today
DBE oDateDBE1 = date(TestCaseHistoryDB, 30, init, true)
DBE timeField = field (TestCaseHistoryDB, "Time : ", "00:00:00", 25)

void makeTestCaseHistory(DB winDB) {

    Date oDate = get(oDateDBE1)
    Date oDate2 = dateOnly oDate

    string sDate = stringOf(oDate)
    string sTime = get timeField
    print sDate " " sTime "\n"
}

apply(TestCaseHistoryDB, "Go", makeTestCaseHistory)
realize(TestCaseHistoryDB)
show(TestCaseHistoryDB)

"

It would be good to add verification of the time value, as it currently stands any string will be accepted.

I can actually leave out the time element altogether for my purposes.

However, there are two problems with this code

When you press the button "Go" you get:

(here is the error msg translated from Spanish to English))

-RE-540, <Line:7> Format or value incorrect, the date (Wednesday, 02  Abril  2014)

It only works if the commented out line 

Date init = dateAndTime(today) is used

Secondly the variable "oDate2" is not used. 

Re: date/time picker control instances
SGreen - Thu Apr 03 12:18:55 EDT 2014

MyDeveloerWorks - Wed Apr 02 09:26:15 EDT 2014

I can actually leave out the time element altogether for my purposes.

However, there are two problems with this code

When you press the button "Go" you get:

(here is the error msg translated from Spanish to English))

-RE-540, <Line:7> Format or value incorrect, the date (Wednesday, 02  Abril  2014)

It only works if the commented out line 

Date init = dateAndTime(today) is used

Secondly the variable "oDate2" is not used. 

I wasn't seeing this due to date format settings on my machine, and changing them is one possible solution.

However, if the value is retrieved from the DBE as a string, it is more robust to different date formats.

So can you try using something like "string sDate = get(oDateDBE1)".